var storage = {

    putDatas: function(formId, searchBar) {
        if (formId !== undefined && formId !== null && formId !== '') {
            var form = document.getElementById(formId);
            for (var i = 0; i < form.elements.length; i++) {
                var ele = form.elements[i];
                if (ele.type != 'button' && ele.type != 'checkbox') {
                    window.localStorage.setItem(this.getPrefix() + ele.name, ele.value);
                }
            }
        }

        if (searchBar !== undefined) {
            var _queryParam = searchBar.getQueryParams();
            if (_queryParam !== undefined && _queryParam !== '') {
                window.localStorage.setItem(this.getPrefix() + 'searchBar', _queryParam);
            }
        }
    },

    getDatas: function(formId, searchBar) {
        if (formId !== undefined && formId !== null && formId !== '') {
            var form = document.getElementById(formId);
            for (var i = 0; i < form.elements.length; i++) {
                var ele = form.elements[i];

                if (ele.type != 'button' && ele.type != 'checkbox') {
                    var val = window.localStorage.getItem(this.getPrefix() + ele.name) || '';
                    if (val !== '') {
                        ele.value = val;
                    }
                }
            }
        }

        if (searchBar !== undefined) {
            var val = window.localStorage.getItem(this.getPrefix() + 'searchBar') || '';
            if (val !== '') {
            	console.log(val);
                searchBar.setValue(val);
            }
        }
    },

    getPrefix: function() {
        return location.hash + "/"; // 获取路径
    }
};